package cn.com.dcsgo.controller;

import cn.com.dcsgo.result.Result;
import cn.com.dcsgo.service.FileUploadService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

/**
 * 使用阿里OSS的文件上传控制器
 *
 * @author Dcsgo
 * @since 2025/4/14 下午7:32
 */
@Api(tags = "文件上传接口")
@RestController
@RequiredArgsConstructor
@RequestMapping("admin/product")
public class FileUploadController {
    private final FileUploadService fileUploadService;

    @ApiOperation("图片上传")
    @PostMapping("fileUpload")
    public Result<String> uploadFile(MultipartFile file) {
        String url = fileUploadService.upload(file);
        return Result.ok(url);
    }
}
